﻿using System.Collections.Generic;
using System.Linq;

namespace Entities.Enumeration {

    public class Currency {

        public readonly static Currency AUD = new Currency("AUD", "澳元",    100);
        public readonly static Currency RMB = new Currency("RMB", "人民币",  200);

        private static readonly Dictionary<int, Currency> TypeIndex =
            new[] { AUD, RMB }.ToDictionary(unit => unit.Type);

        private static readonly Dictionary<string, Currency> NameIndex =
            new[] { AUD, RMB }.ToDictionary(unit => unit.Name);

        private static readonly Dictionary<string, Currency> CNameIndex =
            new[] { AUD, RMB }.ToDictionary(unit => unit.CName); 

        public int    Type  { get; set; }
        public string Name  { get; set; }
        public string CName { get; set; }

        public Currency(string name, string cname, int type) {
            Name  = name;
            CName = cname;
            Type  = type;
        }

        public static Currency GetInstance(int type) {
            switch (type) {
                case 100 : return AUD;
                case 200 : return RMB;
                default  : return AUD;
            }
        }


    }

}